import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Params, Router } from '@angular/router';
import { HttpService } from '../../service/http.service';
import { PTRComponent, ToptipsComponent } from 'ngx-weui';
import { Observable } from 'rxjs/Observable';

@Component({
  selector: 'app-hospindex',
  templateUrl: './hospindex.component.html',
  styleUrls: ['./hospindex.component.css']
})

export class HospindexComponent implements OnInit {
  
  hospindexurl = 'hospital!getHospitalInfoById?h_id=';
  hospid: any;
  hospindex: any;

  @ViewChild('toptips') toptips: ToptipsComponent;
  constructor(public routerdata: ActivatedRoute, private router: Router,
    private listdata: HttpService) {
  }

  ngOnInit() {
    this.routerdata.params.subscribe((params: Params) => this.hospid = params['id']);//从路由取值
    this.getHospData();
  }
  //读取医院详细数据
  getHospData() {
    this.listdata.httpGet(this.hospindexurl+this.hospid, {}).subscribe(res => {
      this.hospindex = res[0];
      console.log('接口名:'+this.hospindexurl, this.hospindex);
    });
  }
}
